<template>
  <div class="current-page">
    <!--审计日志列表页面-->
    <!-- 搜索区域 -->
    <!-- <div class="search-area">
      <div class="search-form">
        <el-form label-width="80px" :model="identform">
          <el-row>
            <el-col :span="8">
              <el-form-item label="序列号">
                <el-input placeholder="请输入序列号" v-model="identform.KeySerial" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="绑定用户">
                <el-input placeholder="请输入绑定用户" v-model="identform.AccountName" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="绑定终端">
                <el-input placeholder="请输入绑定终端" v-model="identform.DevIP" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col style="display: flex; justify-content: flex-end">
              <el-button type="primary" icon="el-icon-edit" @click="editpins">PIN码修改</el-button>
              <el-button type="primary" icon="el-icon-search" @click="handelSearch">搜索</el-button>
              <el-button type="primary" icon="el-icon-plus" @click="clixingods('add')">新增</el-button>
              <el-button type="primary" plain icon="el-icon-upload2" @click="importAdminControl = true">导入数据
              </el-button>
              <el-button type="primary" plain icon="el-icon-upload2" @click="exprdoagods">导出
              </el-button>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div> -->

    <el-row class="yngsds">
      <el-col style="display: flex; justify-content: flex-end">
        <!-- <el-button type="primary" icon="el-icon-search" @click="handelSearch">搜索</el-button> -->
        <!-- <el-button type="primary" icon="el-icon-plus" @click="clixingods('add','')" v-show="userName == 'sysadm'">新增</el-button> -->
        <!-- <el-button type="primary" plain icon="el-icon-upload2" @click="importAdminControl = true">导入数据
        </el-button> -->
        <!-- <el-button type="primary" plain icon="el-icon-upload2" @click="exprdoagods">导出</el-button> -->
        <el-button type="primary" icon="el-icon-edit" @click="editpins">PIN码修改</el-button>
        <el-button type="primary" plain icon="el-icon-unlock" v-show="userName == 'secadm' || userName == 'admin'"
          @click="jieuhsuas">解锁</el-button>
        <el-button type="primary" icon="el-icon-refresh-right" @click="shuaxins">刷新</el-button>
      </el-col>
    </el-row>
    <com-table ref="comTable" :tableData="tableData" url="system/log/local" keyName="XPRO_ARRAY" :has-data="hasData"
      :table-head-list="tableHeadList" :total-count="totalCount" :page-num="pageNum" :searchForm="identform"
      :page-size="pageSize" :page-sizes="pageSizes" :table-loading="loading" :table-height="tableHeight"
      :is-show-select="true" :page-show="false" :handle-show="false" :merge-flag="false" :baddtsd="true"
      @setSearchHeight="setTableHeight" @chooseData="chooseData" @chobangd="clixingods"
      @selectTableData="selectTableData" @deldngd="deldngd">
    </com-table>
    <!-- 新增 -->
    <el-dialog :title="usbkebang" :visible="showAuditDialog" @close="showAuditDialog = false"
      custom-class="alarm-type-detail el-dialog-widthSmall" :close-on-click-modal="false" @closed="auditDialogClosed">
      <div class="dengshus">
        <el-form label-width="80px" :model="formInline">
          <div class="awas">
            <el-form-item label="序列号">
              <el-input v-model="formInline.keySn" placeholder="请输入序列号"></el-input>
            </el-form-item>
          </div>
          <div class="awas">
            <el-form-item label="类型">
              <el-input v-model="formInline.KeysdType" placeholder="请选择类型"></el-input>
            </el-form-item>
          </div>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showAuditDialog = false">取 消</el-button>
        <el-button type="primary" @click="confirmInfo" v-show="usbkebang == 'USBKey新增'">确 定</el-button>
        <el-button type="primary" @click="confixiugaif" v-show="usbkebang == 'USBKey修改'">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 绑定用户/绑定终端 -->
    <el-dialog title="绑定用户/绑定终端" :visible="showDetailinagbangd" @close="showDetailinagbangd = false"
      custom-class="equip-detail el-dialog-widthMiddle" width="30%" @closed="bangdliangshu">
      <div>
        <el-button type="primary" @click="bangdying">绑定用户</el-button>
        <el-button type="primary" @click="bnagsdzhus">绑定终端</el-button>
      </div>
    </el-dialog>
    <!-- 绑定 -->
    <el-dialog title="绑定用户" :visible="showDetailDialog" @close="showDetailDialog = false"
      custom-class="equip-detail el-dialog-widthMiddle" width="60%" @closed="bangdingdalogs">
      <div class="bamnhds">
        <div class="liebs">
          <el-input v-model="rganization" placeholder="请输入组织机构"></el-input>
          <el-tree :data="datasLisdt" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
        </div>
        <div class="biaogri">
          <div class="sos">
            <el-input v-model="rganization" placeholder="请输入关键字"></el-input>
          </div>
          <el-table :data="tableData" style="width: 100%" @select="handleSelectizuhi" @select-all="handleSelectizuhi"
            @selection-change="handleSelectizuhi" :default-sort="{ prop: 'date', order: 'descending' }">
            <el-table-column type="selection" :reserve-selection="true" align="center"></el-table-column>
            <el-table-column prop="KeySerial" label="序号" width="120">
            </el-table-column>
            <el-table-column prop="DevIP" label="账户" sortable>
            </el-table-column>
            <el-table-column prop="UserName" label="姓名" sortable>
            </el-table-column>
            <el-table-column prop="FullDeptName" label="组织机构" sortable>
            </el-table-column>
          </el-table>
          <el-pagination background :page-sizes="[5, 10, 20, 100]" :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper" :total="totalCount"
            style="text-align: center; margin-top: 10px" @size-change="handleSizeChange"
            @current-change="handlePageChange">
          </el-pagination>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showDetailDialog = false">关 闭</el-button>
        <el-button type="primary" @click="bangdinque">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="绑定终端" :visible="showbangzduanlog" @close="showbangzduanlog = false"
      custom-class="equip-detail el-dialog-widthMiddle" width="60%" @closed="bangdlzhongduas">
      <div class="zhondbsts">
        <div class="shaixun">
          <span>操作系统账号 </span>
          <el-select v-model="xitzhanghso" placeholder="请选择">
            <el-option v-for="item in xitzhanlsit" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div class="sous">
          <el-input v-model="rganization" placeholder="请输入关键字"></el-input>
          <el-button type="primary">高级搜索</el-button>
        </div>
        <div class="baiosh">
          <el-table :data="tableData" style="width: 100%" @select="handleSelectizuhi" @select-all="handleSelectizuhi"
            @selection-change="handleSelectizuhi" :default-sort="{ prop: 'date', order: 'descending' }">
            <el-table-column type="selection" :reserve-selection="true" align="center"></el-table-column>
            <el-table-column prop="KeySerial" label="序号" width="120">
            </el-table-column>
            <el-table-column prop="DevIP" label="终端名称" sortable>
            </el-table-column>
            <el-table-column prop="UserName" label="终端唯一标识" sortable>
            </el-table-column>
            <el-table-column prop="FullDeptName" label="ip地址" sortable>
            </el-table-column>
            <el-table-column prop="FullDeptName" label="绑定状态" sortable>
            </el-table-column>
            <el-table-column prop="FullDeptName" label="系统类型" sortable>
            </el-table-column>
          </el-table>
          <el-pagination background :page-sizes="[5, 10, 20, 100]" :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper" :total="totalCount"
            style="text-align: center; margin-top: 10px" @size-change="handleSizeChange"
            @current-change="handlePageChange">
          </el-pagination>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showbangzduanlog = false">关 闭</el-button>
        <el-button type="primary" @click="zhonduqures">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 解锁 -->
    <el-dialog title="解锁" :visible="showjiebangsz" @close="showjiebangsz = false"
      custom-class="equip-detail el-dialog-widthMiddle" width="50%" @closed="showjiebansgsdsz">
      <el-form label-width="100px">
        <div class="awas">
          <el-form-item label="请输入PIN码">
            <el-input style="width: 180px" v-model="jiesuopin" placeholder="请输入Key管理员PIN码"></el-input>
          </el-form-item>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showjiebangsz = false">关 闭</el-button>
        <el-button type="primary" @click="jiebangques">确 定</el-button>
      </span>
    </el-dialog>
    <!-- pin -->
    <el-dialog title="修改PIN码" :visible="absopindlosa" @close="absopindlosa = false"
      custom-class="alarm-type-detail el-dialog-widthSmall" :close-on-click-modal="false" @closed="absopinddlosa">
      <div class="dengshus">
        <el-form label-width="120px" ref="formpinsxe" :model="formpinsxe" :rules="rules">
          <div class="awas">
            <el-form-item label="输入旧PIN码">
              <el-input v-model="formpinsxe.pin" type="password" placeholder="请输入旧PIN码"></el-input>
            </el-form-item>
          </div>
          <div class="awas">
            <el-form-item label="输入新PIN码" prop="newPin">
              <el-input v-model="formpinsxe.newPin" type="password" placeholder="请输入新PIN码"></el-input>
            </el-form-item>
          </div>
          <div class="awas">
            <el-form-item label="确认新PIN码">
              <el-input v-model="formpinsxe.newPin1" type="password" placeholder="请确认新PIN码"></el-input>
            </el-form-item>
          </div>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="absopindlosa = false">取 消</el-button>
        <el-button type="primary" @click="pinabsoclis">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 导入 -->
    <data-import-dialog title="选择导入文件" :show.sync="importAdminControl" exportTemplateUrl="./static/export-template.xlsx"
      importDataUrl="/dzqzManager/importManagers.do" extendFileName="xlsx,xls" @importCallback="theImportCallback"
      requestType="localhost" custom-class="equip-detail-deviceInfo" :pageType="pageType"></data-import-dialog>
  </div>
</template>
<script>
import QS from "qs";
import ComTable from "../../components/table/comTable";
import dataImportDialog from "../../components/common/dataImportDialog.vue";
export default {
  name: "USBkeyAdmin",
  data() {
    return {
      accountNameOnline: "",
      pageNum: 1, // 当前页
      pageSize: 10,
      pageSizes: [5, 10, 20, 100],
      totalCount: 0, //共多少条数据
      tableHeight: "", // 表格高度
      hasData: true,
      showjiebangsz: false,
      identform: {
        KeySerial: "",
        AccountName: "",
        DevIP: "",
      },
      importAdminControl: false,
      pageType: "1",
      tableHeadList: [
        {
          colDisabled: false,
          colHidden: false,
          colSearch: true,
          colSort: false,
          columnComment: "序列号",
          columnName: "keySn",
        },
        {
          colDisabled: false,
          colHidden: false,
          colSearch: true,
          colSort: false,
          columnComment: "Key类型",
          columnName: "keyType",
        },
        {
          colDisabled: false,
          colHidden: false,
          colSearch: true,
          colSort: false,
          columnComment: "Key状态",
          columnName: "leftRetry",
        },
        {
          colDisabled: false,
          colHidden: false,
          colSearch: true,
          colSort: false,
          columnComment: "Key名称",
          columnName: "keyName",
        },
      ],
      tableData: [],
      formInline: {
        keySn: "",
        KeysdType: "",
      },
      rganization: "", //组织机构
      loading: false, // 数据加载状态遮罩
      dialogTitle: "",
      showbangzduanlog: false, // 绑定zhonduan
      showAuditDialog: false, //新增
      showDetailDialog: false, // 绑定用户
      showDetailinagbangd: false,
      multipleSelection: [],
      datasLisdt: [
        {
          label: "一级 1",
          children: [
            {
              label: "二级 1-1",
              children: [
                {
                  label: "三级 1-1-1",
                },
              ],
            },
          ],
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
      xitzhanghso: "",
      xitzhanlsit: [],
      usbkebang: "",
      absopindlosa: false,
      formpinsxe: {
        newPin: "",
        pin: "",
        newPin1: "",
      },
      userName: "",
      seslvae: {},
      jiesuopin: "",
      dhuslist: [],
      forinsm: {},
      rules: {
        newPin: [
          // { required: true, message: "输入新PIN码", trigger: "blur" },
          // {
          //   pattern: this.pinNews,
          //   message: this.pinmessa,
          //   trigger: "blur",
          // },
          {
            required: true,
            validator: this.bargainMoney,
            trigger: "blur",
          },
        ],
      },
      pinNews: "",
      pinmessa: "",
      timestamp: "", //时间戳
      empIds: "",
      empNames: "",
    };
  },
  components: {
    ComTable,
    dataImportDialog,
  },
  created() {
    this.userName = window.sessionStorage.getItem("userName");
    console.log(this.userName);
    this.timestamp = new Date().getTime();
    this.setTableHeight();
    // this.datalists();
    this.getHostInfo();
  },
  methods: {
    getHostInfo () {
      this.$get(`/vgmp/config/gethostinfo`).then((res) => {
        console.log(res.data.data);
        this.empIds = res.data.data.empID
        this.empNames = res.data.data.empName
        this.getUserData()
      });
    },
    // 刷新
    shuaxins() {
      this.datalists();
    },
    datalists() {
      this.$get("/aqdl/key/list_key").then((res) => {
        console.log(res);
        res.data.data.keyArray.forEach((item) => {
          if (item.leftRetry == "0") {
            item.leftRetry = "已锁定";
          } else {
            item.leftRetry = "正常";
          }
        });
        this.tableData = res.data.data.keyArray;
        this.totalCount = parseInt(res.data.data.keyArray.length);
      });
    },
    headerCellStyle({ row, column, rowIndex, columnIndex }) {
      return {
        "font-size": "14px",
        "font-weight": 600,
        color: "#606266",
      };
    },

    // 获取
    bargainMoney(rule, value, callback) {
      this.$get("/aqdl/policy/getcontext?type=25").then((res) => {
        console.log(res);
        this.forinsm = res.data.data.policy[0].context.Root;
        let data = res.data.data.policy[0].context.Root;

        if (data.Complex == "3") {
          this.pinNews = new RegExp(
            `^(?=.*\\d)(?=.*[a-zA-Z])[\\da-zA-Z]{${this.forinsm.PINLengthS},${this.forinsm.PINLengthE}}$`,
            "i"
          );
          this.pinmessa = `PIN码长度为${this.forinsm.PINLengthS}到${this.forinsm.PINLengthE}，PIN码包含字母和数字`;
        } else if (data.Complex == "5") {
          this.pinNews = new RegExp(
            "^(?=.*[a-zA-Z])(?=.*[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？])[a-zA-Z`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]" +
            `{${this.forinsm.PINLengthS},${this.forinsm.PINLengthE}}$`,
            "i"
          );
          this.pinmessa = `PIN码长度为${this.forinsm.PINLengthS}到${this.forinsm.PINLengthE}，PIN码包含字母和特殊符号`;
        } else if (data.Complex == "6") {
          this.pinNews = new RegExp(
            "^(?=.*\\d)(?=.*[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？])[\\d`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]" +
            `{${this.forinsm.PINLengthS},${this.forinsm.PINLengthE}}$`
          );
          this.pinmessa = `PIN码长度为${this.forinsm.PINLengthS}到${this.forinsm.PINLengthE}，PIN码包含数字和特殊符号`;
        } else if (data.Complex == "7") {
          this.pinNews = new RegExp(
            "^(?=.*\\d)(?=.*[a-zA-Z])(?=.*[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？])[\\da-zA-Z`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]" +
            `{${this.forinsm.PINLengthS},${this.forinsm.PINLengthE}}$`,
            "i"
          );
          this.pinmessa = `PIN码长度为${this.forinsm.PINLengthS}到${this.forinsm.PINLengthE}，PIN码包含字母数字和特殊符号`;
        } else if (data.Complex == "1") {
          this.pinNews = new RegExp(
            `^[a-z]{${this.forinsm.PINLengthS},${this.forinsm.PINLengthE}}$`,
            "i"
          );
          this.pinmessa = `PIN码长度为${this.forinsm.PINLengthS}到${this.forinsm.PINLengthE}的字母`;
        } else if (data.Complex == "2") {
          this.pinNews = new RegExp(
            `^\\d{${this.forinsm.PINLengthS},${this.forinsm.PINLengthE}}$`
          );
          this.pinmessa = `PIN码长度为${this.forinsm.PINLengthS}到${this.forinsm.PINLengthE}的数字`;
        } else if (data.Complex == "4") {
          this.pinNews = new RegExp(
            "^[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]" +
            `{${this.forinsm.PINLengthS},${this.forinsm.PINLengthE}}$`
          );
          this.pinmessa = `PIN码长度为${this.forinsm.PINLengthS}到${this.forinsm.PINLengthE}的特殊符号`;
        }
        console.log(value, this.pinNews, this.pinNews.test(value));
        if (value == null || String(value).trim() === "") {
          return callback(new Error("不能为空"));
        } else if (!this.pinNews.test(value)) {
          // return callback(new Error(this.pinmessa));
          this.$message({
            message: this.pinmessa,
            type: "warning",
          });
          this.formpinsxe.newPin = "";
        } else {
          return callback();
        }
      });
    },
    // 选中项发生变化
    handleSelectionChange(val) {
      console.log(val, 246);
      this.multipleSelection = val;
    },
    handleSelectizuhi(val) {
      console.log(val);
    },
    // 新增
    clixingods(daa, row) {
      console.log(daa, row);
      if (daa == "add") {
        this.usbkebang = "USBKey新增";
      } else {
        this.usbkebang = "USBKey修改";
        this.formInline = row;
      }
      this.showAuditDialog = true;
    },
    // 新增确认
    confirmInfo() {
      let data = {
        keySn: this.formInline.keySn,
        keyType: this.formInline.KeysdType,
      };
      this.$postForJson("/aqdl/key/list_key", data).then((res) => {
        console.log(res);
        if (res.data.errorcode == 0) {
          this.showAuditDialog = false;
          this.$message({
            message: "新增成功!",
            type: "success",
          });
        }
      });

      this.formInline = {};
    },
    // 修改
    confixiugaif() {
      let data = {
        keySn: this.formInline.keySn,
        keyType: this.formInline.KeysdType,
      };
      this.$postForJson("/aqdl/key/list_key", data).then((res) => {
        console.log(res);
        if (res.data.errorcode == 0) {
          this.showAuditDialog = false;
          this.$message({
            message: "修改成功!",
            type: "success",
          });
        }
      });
      this.formInline = {};
    },
    selectTableData(val) {
      console.log(val);
      this.seslvae = val[0];
      this.dhuslist = val;
      console.log(this.seslvae);
    },
    jieuhsuas() {
      console.log(this.dhuslist);
      if (this.dhuslist.length == "0") {
        this.$message({
          message: "请选择一条数据",
          type: "warning",
        });
      } else {
        this.showjiebangsz = true;
      }
    },
    // 解锁
    jiebangques() {
      let data = {
        keySerial: {
          keySn: this.seslvae.keySn,
          keyType: this.seslvae.keyType,
        },
        pinInfo: {
          type: "1",
          pin: this.jiesuopin,
        },
      };
      this.$postForJson("/aqdl/key/verify_pin", data).then((res) => {
        console.log(res);
        let datas = res.data;
        if (datas.errorcode == 0) {
          this.$message({
            message: "解锁成功!",
            type: "success",
          });
          this.showjiebangsz = false;
          this.setlogrlist("290", datas.errorcode, "成功");
        } else {
          this.$message({
            message: `解锁失败，剩余尝试次数${datas.leftretry}`,
            type: "error",
          });
          this.setlogrlist("290", datas.errorcode, "失败");
        }
        this.jiesuopin = "";
      });
    },

    /**
     * 关闭对话框dialog
     */
    auditDialogClosed() {
      this.showAuditDialog = false;
    },
    bangdingdalogs() {
      this.showDetailDialog = false;
    },
    // 绑定用户确定
    bangdinque() {
      this.showDetailDialog = false;
    },
    handleNodeClick(data) {
      console.log(data);
    },
    // 绑定
    chooseData(val) {
      console.log(val);
      this.showDetailinagbangd = val;
    },
    // 关闭
    bangdliangshu() {
      this.showDetailinagbangd = false;
    },
    // 绑定用户
    bangdying() {
      this.showDetailinagbangd = false;
      this.showDetailDialog = true;
    },
    // 绑定终端
    bnagsdzhus() {
      this.showDetailinagbangd = false;
      this.showbangzduanlog = true;
    },
    bangdlzhongduas() {
      this.showbangzduanlog = false;
    },
    zhonduqures() {
      this.showbangzduanlog = false;
    },
    showjiebansgsdsz() {
      this.showjiebangsz = false;
    },
    // pin码修改
    editpins() {
      if (this.dhuslist.length == "0") {
        this.$message({
          message: "请选择一条数据",
          type: "warning",
        });
      } else {
        this.absopindlosa = true;
      }
    },
    pinabsoclis() {
      let json = {
        keySerial: {
          keySn: this.seslvae.keySn,
          keyType: this.seslvae.keyType,
        },
        pinInfo: {
          type: "2",
          pin: this.formpinsxe.pin,
        },
      };
      this.$postForJson("/aqdl/key/verify_pin", json).then((res) => {
        if (res.data.errorcode != 0) {
          this.$message({
            message: "请输入正确的PIN码",
            type: "warning",
          });
          this.formpinsxe.newPin = "";
          this.formpinsxe.newPin1 = "";
          // this.setlogrlist("296", res.data.errorcode, "失败");
        } else {
          // this.setlogrlist("296", res.data.errorcode, "成功");
          if (this.formpinsxe.newPin1 == this.formpinsxe.newPin) {
            this.$refs.formpinsxe.validate((valid) => {
              if (valid) {
                let data = {
                  keySerial: {
                    keySn: this.seslvae.keySn,
                    keyType: "273",
                  },
                  pinInfo: {
                    type: "2",
                    pin: this.formpinsxe.pin,
                    newPin: this.formpinsxe.newPin,
                  },
                };
                this.$postForJson("/aqdl/key/set_pin", data).then((res) => {
                  console.log(res);
                  let datas = res.data;
                  if (datas.errorcode == 0) {
                    this.$message({
                      message: "修改成功!",
                      type: "success",
                    });
                    this.setlogrlist("289", datas.errorcode, "成功");
                  } else {
                    this.$message({
                      message: `修改失败，剩余尝试次数${datas.leftretry}`,
                      type: "error",
                    });
                    this.setlogrlist("289", datas.errorcode, "失败");
                  }
                });
                this.absopindlosa = false;
              } else {
              }
            });
          } else {
            this.formpinsxe = {};
            this.$message({
              message: "新PIN码输入不一致",
              type: "warning",
            });
          }
        }
      });
    },
    //获取账户
    getUserData() {
      this.$get("/aqdl/user/getloginuser").then((res) => {
        console.log(res, 293);
        this.accountNameOnline = res.data.data;
        this.datalists();
      });
    },
    //10位时间戳转换
    getLocalTime(nS) {
      let time = new Date(parseInt(nS) * 1000)
        .toLocaleString()
        .replace(/:\d{1,2}$/, " ")
        .replace(/\//g, "-");
      // 找出出现空格的位置
      let space_position = time.indexOf(" ");
      // 截取并返回数据
      return time.slice(0, space_position);
    },
    // 记录操作日志接口
    setlogrlist(tyid, sults, redusl) {
      let eTimes = (new Date().getTime()+ '').substring(0, 10)
      console.log(eTimes, "Timestamp");
      let that = this;
      let KeySerial = '- -'
      this.$get("/aqdl/key/list_key").then(res => {
        console.log(res)
        if (res.data.data.keyArray.length != 0) {
          KeySerial = res.data.data.keyArray[0].keySn
        }
        let daJson = {
          "Root": {
            "LogType": "50",
            "LogRecord": {
              "Timestamp": eTimes + "",
              "EmpID": this.empIds,
              "EmpName": this.empNames,
              "Type": tyid,
              "KeySerial": KeySerial,
              "KeyType": "273",
              "Account": this.accountNameOnline,
              "Role": "admin",
              "Result": sults + "",
              "ResultDesc": redusl,
            },
          },
        }
        let daJsons = {
          "Root": {
            "LogType": "50",
            "LogRecord": {
              "Timestamp": eTimes + "",
              "EmpID": this.empIds,
              "EmpName": this.empNames,
              "Type": tyid,
              "KeySerial": KeySerial,
              "KeyType": "273",
              "Account": this.accountNameOnline,
              "Role": "user",
              "Result": sults + "",
              "ResultDesc": redusl,
            },
          },
        }
        that.$postForJson("/aqdl/auditlog/setlogrecord", daJsons).then((res) => {
          console.log(res);
          that.$postForJson("/aqdl/auditlog/setlogrecord", daJson).then((res) => {
            console.log(res);
            if (tyid == "289" && redusl == "成功") {
              // that.setlogrlist("296", "0", "成功");
            } else if (tyid == "289" && redusl == "失败") {
              // that.setlogrlist("296", "1", "失败");
            }
          })
        })
      })
    },
    /**
     * 设置表格的高度
     */
    setTableHeight() {
      let clientHeiht =
        window.innerHeight || document.documentElement.clientHeight;
      this.tableHeight = clientHeiht - 160;
    },
    /**
     * 表格序号
     * @param index {Number} 表格索引值
     * @return currentIndex 处理后的表格序号
     */
    indexMethod(index) {
      let currentIndex;
      if (this.pageNum === 1) {
        currentIndex = index + this.pageNum;
      } else {
        let page = (this.pageNum - 1) * this.pageSize;
        currentIndex = index + 1 + page;
      }
      return currentIndex;
    },

    /**
     * 切换每页条数
     */
    handleSizeChange(value) {
      this.pageSize = value;
    },

    /**
     * 切换页码
     */
    handlePageChange(value) {
      this.pageNum = value;
    },
    /**
     * 搜索按钮
     */
    handelSearch() {
      this.datalists();
      this.multipleSelection = [];
    },
    deldngd() {
      this.$confirm("确认是否删除？", "提示", {
        confirmButtonText: "确 定",
        cancelButtonText: "取 消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            message: "删除成功!",
            type: "success",
          });
        })
        .catch((_) => { });
    },
    chobangd() {
      this.showjiebangsz = true;
    },
    butzbangds(d) {
      this.showjiebangsz = false;
      if (d == "1") {
        this.$confirm("确认是否解绑用户？", "提示", {
          confirmButtonText: "确 定",
          cancelButtonText: "取 消",
          type: "warning",
        })
          .then(() => {
            this.$message({
              message: "解绑成功!",
              type: "success",
            });
          })
          .catch((_) => { });
      } else {
        this.$confirm("确认是否解绑终端？", "提示", {
          confirmButtonText: "确 定",
          cancelButtonText: "取 消",
          type: "warning",
        })
          .then(() => {
            this.$message({
              message: "解绑成功!",
              type: "success",
            });
          })
          .catch((_) => { });
      }
    },
    // 导出回调
    theImportCallback(val) {
      if (val.success) {
        const h = this.$createElement;
        this.$msgbox({
          title: "消息",
          message: h("div", null, [
            h("p", { fontSize: "18px" }, "上传结果："),
            h("p", null, `共上传${val.results.totalNum}条`),
            h(
              "p",
              { style: { color: "#67C23A" } },
              `成功${val.results.succeedNum}条`
            ),
            h(
              "p",
              { style: { color: "#F56C6C" } },
              `失败${val.results.errorNum}条`
            ),
          ]),
          showCancelButton: false,
          confirmButtonText: "确定",
          type: "warning",
        }).then(() => {
          console.log(111);
          // this.getTableInfo(this.currentPage, this.pagesize);
        });
      }
    },
    absopinddlosa() {
      this.formpinsxe = {};
    },
    // 导出
    exprdoagods() {
      //  $("#downloadFile").attr("src", window.root + url);
    },
  },

  filters: {},
};
</script>

<style scoped>
@import "../../assets/css/commonTable.css";

.alarm-row {
  width: 80%;
}

.icon-shenjiguanli {
  font-size: 14px;
}

.tip-area {
  padding: 8px 16px;
  background-color: #ecf8ff;
  border-radius: 4px;
  border-left: 5px solid #50bfff;
  margin: 0 0 20px 0;
}

.search-area {
  display: flex;
}

.current-page .search-area .search-form {
  width: 100%;
}

.dengshus .awas {
  width: 60%;
  margin: 20px auto;
}

.bamnhds {
  display: flex;
  border-top: 2px solid #ccc;
}

.zhondbsts {
  /* border-top: 2px solid #ccc; */
  display: flex;
  flex-direction: column;
}

.bamnhds .liebs {
  width: 20%;
  border-right: 1px solid #ccc;
}

.bamnhds .biaogri {
  width: 75%;
}

.bamnhds .biaogri .sos {
  width: 30%;
  margin: 10px;
  float: right;
}

.el-dialog__body {
  padding: 0;
}

:deep(.el-dialog__body) {
  text-align: center;
}

:deep(.el-dialog__footer) {
  text-align: center;
}

:deep(.el-tree, .leftCol) {
  background: #fff;
}

.zhondbsts .shaixun {
  border-bottom: 1px solid #ccc;
  padding: 10px;
  padding-left: 38%;
  border-top: 1px solid #ccc;
}

.zhondbsts .sous {
  width: 30%;
  display: flex;
  padding: 10px;
  margin-left: 70%;
}

.zhondbsts .baiosh {
  border-top: 1px solid #ccc;
}

.yngsds {
  margin-bottom: 10px;
}
</style>
